<?php
/**
 * Created by PhpStorm.
 * User: yekong
 * Date: 2018/3/21
 * Time: 下午3:05
 */


$servername = "127.0.0.1";
$username = "root";
$password = "123456";

// 创建连接
$conn = new mysqli($servername, $username, $password,'new_schema');

// 检测连接
if ($conn->connect_error) {
    die("连接失败: " . $conn->connect_error);
}
echo "连接成功";


$sql = "SELECT * FROM user";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    // 输出数据
    while($row = $result->fetch_assoc()) {
    print_r($row);
    }
} else {
    echo "0 结果";
}
$conn->close();
exit;
    $say = $_POST['say'];
    if(empty($say))exit(json_encode(array('answer' => "说话啊傻逼")));
    $answer['all'] = array('好个jb', '你是傻逼吗', '你怎么什么都不会', '1+1等于多少?', '我是你爸爸', '滚滚滚');
    $answer['好'] = array('好个jb', '好你mb', '劳资一点都不好', '滚滚滚');
    $answer['滚'] = array('你丑你先滚','你滚,劳资不想看到你这个傻逼');
    $answer['傻'] = array('你个傻b再说一次', '傻人有傻福,但你这样的傻逼没有');
    $answer['日'] = array('来啊', '我裤子都脱了', '歪? 我ri尼玛');
    $answer['草'] = array('我怀疑你是条哈士奇', '看你这个样子不日条狗消停不下来');


    $key = array('好', '滚', '傻', '日', '草');

    foreach($key as $val){
        if(false !== strpos($say, $val)){
            exit(json_encode(array('answer' => $answer[$val][array_rand($answer[$val], 1)])));
        }
    }

    exit(json_encode(array('answer' => $answer['all'][array_rand($answer['all'], 1)] )));